package com.ccx.llm.llmservice.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private Integer code;
    private String msg;
    private Object data;

    public static R success(String msg, Object data) {
        return new R(CodeEnum.SUCCESS.getCode(), msg, data);
    }

    public static R success(Object data) {
        return success(null, data);
    }

    public static R success() {
        return success(null, null);
    }

    public static R fail(String msg, Object data) {
        return new R(CodeEnum.FAIL.getCode(), msg, data);
    }

    public static R fail(String msg) {
        return fail(msg, null);
    }

    public static R fail() {
        return fail(null, null);
    }

    @Getter
    public enum CodeEnum {
        SUCCESS(1),
        FAIL(0);

        private final Integer code;

        CodeEnum(Integer code) {
            this.code = code;
        }
    }
}
